<template>
  <div>
    <span>我是user/index.vue</span>
    <nuxt-link to="user/one">点我跳转1</nuxt-link>
    <button type="button" @click="jumpUrl">动态跳转</button>
    <button type="button" @click="jumpErrorMsg">动态跳转</button>
<br/><br/><br/><br/>
    <nuxt-link :to="{name:'user-id', params:{id:1002}}">id id id</nuxt-link>
    <nuxt-link :to="{name:'user-name', params:{name:1003}}">name name name</nuxt-link>
  </div>
</template>

<script>
import Vue from 'vue'

export default Vue.extend({
  name: 'userIndexPage',
  methods:{
    jumpUrl() {
      //动态路由 跳转传参
      this.$router.push({name:'user-id', params:{id: 1002}})
    },
    // 模拟报错
    jumpErrorMsg() {
      // ajax.post()通常接口 请求后 后端数据有问题 会报错
      this.$nuxt.error({ statusCode: 404, message: '我找不到页面' });
    }
  },
  mounted() {
    // this.$router.push({name:'user-name', params:{id:1002}})
  },
})
</script>
